package io.wongxd.demo.page.views

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.wongxd.demo.M
import io.wongxd.solution.baseView.BaseComposeToolBarFgt
import io.wongxd.solution.compose.custom.views.other.VerticalSpace
import io.wongxd.solution.compose.custom.views.text_field.GoodTextField
import io.wongxd.solution.compose.custom.views.text_field.HintComposeWithTextField
import io.wongxd.solution.compose.custom.views.text_field.PasswordTextField
import io.wongxd.solution.compose.custom.views.util.rememberMutableStateOf

class FgtViewTextFiled : BaseComposeToolBarFgt() {
    override fun lazyInit() {

    }

    override val title: String
        get() = "FgtViewTextFiled"

    @Composable
    override fun Render() {
        ComposeContent()
    }

    @Composable
    private fun ComposeContent() {
        Column(
            M
                .padding(20.dp)
                .width(200.dp)
        ) {
            val text1 = rememberMutableStateOf("我是账号")
            var text2 by rememberMutableStateOf("")
            val password = rememberMutableStateOf("password")
            val passwordIsShow = rememberMutableStateOf(false)
            val password2 = rememberMutableStateOf("123456")
            val passwordIsShow2 = rememberMutableStateOf(true)
            GoodTextField(
                value = text1.value,
                onValueChange = text1::value::set,
                modifier = M.height(40.dp)
            )
            VerticalSpace(dp = 16)
            GoodTextField(
                value = text2,
                onValueChange = { text2 = it },
                hint = remember {
                    HintComposeWithTextField.createTextHintCompose("请输入账号")
                },
                modifier = M.height(40.dp)
            )
            VerticalSpace(dp = 16)
            PasswordTextField(
                value = password.value,
                onValueChange = { password.value = it },
                passwordIsShow = passwordIsShow.value,
                onPasswordIsShowChange = { passwordIsShow.value = it },
                modifier = M.height(40.dp)
            )
            VerticalSpace(dp = 16)
            PasswordTextField(
                value = password2.value,
                onValueChange = { password2.value = it },
                passwordIsShow = passwordIsShow2.value,
                onPasswordIsShowChange = { passwordIsShow2.value = it },
                modifier = M.height(40.dp)
            )
        }
    }

    @Preview(showBackground = true, backgroundColor = 0xffffffff)
    @Composable
    fun RenderPreView() {

    }
}